home *** CD-ROM | disk | FTP | other *** search
- #include <Palette.h>
-
- /************************************
- * *
- * RedLetters -- by Kenneth Lu *
- * *
- * (Kenneth_K._Lu@BMUG.org) *
- * *
- * 5/1/94 *
- * *
- ************************************/
-
-
- int TheBitDepth(WindowPtr theWindow);
-
- main()
- {
- RGBColor c;
- long i, j, k, oldTicks;
- Boolean down;
- PaletteHandle pal;
- WindowPtr window;
- Rect r;
- char s[11] = {"REDLETTERS"};
- CTabHandle cTab;
- ColorSpec cSpecs[16];
- EventRecord e;
-
- ToolBoxInit();
-
- SetRect(&r, 100, 100, 275, 140);
- window = NewCWindow(NULL, &r, "\pRedLetters", TRUE, noGrowDocProc, MOVE_FRONT, TRUE, 0L);
- SetPort(window);
-
- FillRect(&(window->portRect), black);
-
- k = TheBitDepth(window);
- if ( !((k == 4) || (k == 8)) )
- {
- ShowCursor();
- Alert(BASE_ID, NULL);
- ExitToShell();
- }
-
- pal = NewPalette(256, NULL, pmAnimated, 0x0000);
- c.green = 0;
- c.blue = 0;
-
- for(i=0; i<16; i++)
- {
- c.red = i*16*65535/240;
- SetEntryColor(pal, i, &c);
- }
-
- SetPalette(window, pal, TRUE);
-
- TextFont(newYork);
- TextFace(bold);
- TextSize(24);
-
- for(i=0,j=9; i<10; i++,j--)
- {
- MoveTo(10+(i*16), 30);
- PmForeColor(j);
- DrawChar(s[i]);
- }
-
- i=0;
-
- cTab=(CTabHandle)NewHandle(8+(16*8));
- HLock((Handle)cTab);
- (**cTab).ctSeed = GetCTSeed();
- (**cTab).ctSize = 15;
-
- while(TRUE)
- {
- oldTicks = Ticks;
- for (j=0; j<16; j++)
- {
- if (down)
- k=i-j;
- else
- k=i+j;
- if (down && (k<0))
- k = -k;
- else if (k>15)
- k = 15-(k-15);
- c.red = k*16*65535/240;
- (**cTab).ctTable[j].value = j;
- (**cTab).ctTable[j].rgb = c;
- // AnimateEntry (window, j, &c);
- }
-
-
- AnimatePalette (window, cTab, 0, 0, 16);
-
- if (down)
- i--;
- else
- i++;
- if (i>15)
- {
- down = TRUE;
- i -= 2;
- }
- if (i<0)
- {
- down = FALSE;
- i += 2;
- }
- if (WaitNextEvent (mDownMask, &e, 0, NULL))
- {
- k = FindWindow(e.where, &window);
- if (k = inGoAway)
- if (TrackGoAway (window, e.where))
- ExitToShell();
-
- }
- while (oldTicks+3>Ticks);
- }
- HUnlock((Handle)cTab);
- }
-
- /******************* ToolBoxInit ***********/
-
- ToolBoxInit()
- {
- InitGraf(&thePort);
- InitFonts();
- FlushEvents(everyEvent, 0);
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(NULL);
- InitCursor();
- }
-
- /********* TheBitDepth ***********/
-
- int TheBitDepth(WindowPtr theWindow)
- {
- PixMapHandle thePixMap;
-
- thePixMap = ((CWindowPtr)theWindow)->portPixMap;
- return ((**thePixMap).pixelSize);
- }
-
-